/**
 * droppable - jQuery EasyUI
 * 
 * Licensed under the GPL: http://www.gnu.org/licenses/gpl.txt
 * 
 * Copyright 2010 stworthy [ stworthy@gmail.com ]
 */
(function($) {
	function init(target) {
		$(target).addClass('droppable');
		$(target).bind(
				'_dragenter',
				function(e, source) {
					$.data(target, 'droppable').options.onDragEnter.apply(
							target, [ e, source ]);
				});
		$(target).bind(
				'_dragleave',
				function(e, source) {
					$.data(target, 'droppable').options.onDragLeave.apply(
							target, [ e, source ]);
				});
		$(target).bind(
				'_dragover',
				function(e, source) {
					$.data(target, 'droppable').options.onDragOver.apply(
							target, [ e, source ]);
				});
		$(target).bind(
				'_drop',
				function(e, source) {
					$.data(target, 'droppable').options.onDrop.apply(target, [
							e, source ]);
				});
	}

	$.fn.droppable = function(options) {
		options = options || {};
		return this.each(function() {
			var state = $.data(this, 'droppable');
			if (state) {
				$.extend(state.options, options);
			} else {
				init(this);
				$.data(this, 'droppable', {
					options : $.extend({}, $.fn.droppable.defaults, options)
				});
			}
		});
	};

	$.fn.droppable.defaults = {
		accept : null,
		onDragEnter : function(e, source) {
		},
		onDragOver : function(e, source) {
		},
		onDragLeave : function(e, source) {
		},
		onDrop : function(e, source) {
		}
	};
})(jQuery);